-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handling flaky tests #732
Handling flaky tests #732
Conversation
Codecov Report
@@ Coverage Diff @@
## main #732 +/- ##
=====================================
Coverage 94.4% 94.5%
=====================================
Files 43 43
Lines 3434 3463 +29
=====================================
+ Hits 3245 3273 +28
- Misses 189 190 +1
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks effective, thanks.
Per the changes to the files, I think it would be better to do something like:
# Define a mark as a module global
FLAKY = pytest.mark.flaky(
reruns=5
rerun_delay=2,
condition="GITHUB_ACTIONS" in os.environ and sys.platform == "darwin",
reason="Flaky; See iiasa/message_ix#731"
)
…
# Use the mark to decorate multiple tests
@FLAKY
def test_add_bound_activity_up_all_modes(message_test_mp):
…
Two reasons:
- A general heuristic (not sure where or from which example I picked it up) for pytest usage is to organize tests (modules, files, classes, and functions) by functional meaning or in a way that mirrors the organization of the code being tested. For instance, we might have a
class TestPlatform
that collects tests ofclass Platform
. This makes it easy to navigate.
If these tests cease to be flaky (for instance, with a newixmp4
backend) then the class grouping would no longer be meaningful and we'd have to move the tests out again. - It would create minimally-invasive, small diffs.
- It would be clear when multiple tests are marked in the same meaning, without having to read an compare the function arguments.
Thank you for the comment, I agree that your suggestion is more elegant. I will re-work this PR and the other ones. |
1316d3f
to
d65e36b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to go, thanks for the thorough and clean work.
Closes #731 by marking tests as flaky. Through discussion with @khaeru, we agreed that this is the best option for now; should the tests make more issues in the future, we can still identify their root cause.
How to review
PR checklist
[ ] Add, expand, or update documentation.Nothing new added.[ ] Update release notes.Nothing public-facing added